# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.NetworkServices.V1.Model.ExtensionChainExtension do
  @moduledoc """
  A single extension in the chain to execute for the matching request.

  ## Attributes

  *   `authority` (*type:* `String.t`, *default:* `nil`) - Optional. The `:authority` header in the gRPC request sent from Envoy to the extension service. Required for Callout extensions. This field is not supported for plugin extensions. Setting it results in a validation error.
  *   `failOpen` (*type:* `boolean()`, *default:* `nil`) - Optional. Determines how the proxy behaves if the call to the extension fails or times out. When set to `TRUE`, request or response processing continues without error. Any subsequent extensions in the extension chain are also executed. When set to `FALSE` or the default setting of `FALSE` is used, one of the following happens: * If response headers have not been delivered to the downstream client, a generic 500 error is returned to the client. The error response can be tailored by configuring a custom error response in the load balancer. * If response headers have been delivered, then the HTTP stream to the downstream client is reset.
  *   `forwardHeaders` (*type:* `list(String.t)`, *default:* `nil`) - Optional. List of the HTTP headers to forward to the extension (from the client or backend). If omitted, all headers are sent. Each element is a string indicating the header name.
  *   `metadata` (*type:* `map()`, *default:* `nil`) - Optional. The metadata provided here is included as part of the `metadata_context` (of type `google.protobuf.Struct`) in the `ProcessingRequest` message sent to the extension server. The metadata is available under the namespace `com.google....`. For example: `com.google.lb_traffic_extension.lbtrafficextension1.chain1.ext1`. The following variables are supported in the metadata: `{forwarding_rule_id}` - substituted with the forwarding rule's fully qualified resource name. This field is subject to following limitations: * The total size of the metadata must be less than 1KiB. * The total number of keys in the metadata must be less than 20. * The length of each key must be less than 64 characters. * The length of each value must be less than 1024 characters. * All values must be strings. This field is not supported for plugin extensions. Setting it results in a validation error.
  *   `name` (*type:* `String.t`, *default:* `nil`) - Required. The name for this extension. The name is logged as part of the HTTP request logs. The name must conform with RFC-1034, is restricted to lower-cased letters, numbers and hyphens, and can have a maximum length of 63 characters. Additionally, the first character must be a letter and the last a letter or a number.
  *   `service` (*type:* `String.t`, *default:* `nil`) - Required. The reference to the service that runs the extension. To configure a callout extension, `service` must be a fully-qualified reference to a [backend service](https://cloud.google.com/compute/docs/reference/rest/v1/backendServices) in the format: `https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/backendServices/{backendService}` or `https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices/{backendService}`. To configure a plugin extension, `service` must be a reference to a [`WasmPlugin` resource](https://cloud.google.com/service-extensions/docs/reference/rest/v1beta1/projects.locations.wasmPlugins) in the format: `projects/{project}/locations/{location}/wasmPlugins/{plugin}` or `//networkservices.googleapis.com/projects/{project}/locations/{location}/wasmPlugins/{wasmPlugin}`. Plugin extensions are currently supported for the `LbTrafficExtension` and the `LbRouteExtension` resources.
  *   `supportedEvents` (*type:* `list(String.t)`, *default:* `nil`) - Optional. A set of events during request or response processing for which this extension is called. This field is required for the `LbTrafficExtension` resource. It is optional for the `LbRouteExtension` resource. If unspecified `REQUEST_HEADERS` event is assumed as supported.
  *   `timeout` (*type:* `String.t`, *default:* `nil`) - Optional. Specifies the timeout for each individual message on the stream. The timeout must be between `10`-`1000` milliseconds. Required for callout extensions. This field is not supported for plugin extensions. Setting it results in a validation error.
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :authority => String.t() | nil,
          :failOpen => boolean() | nil,
          :forwardHeaders => list(String.t()) | nil,
          :metadata => map() | nil,
          :name => String.t() | nil,
          :service => String.t() | nil,
          :supportedEvents => list(String.t()) | nil,
          :timeout => String.t() | nil
        }

  field(:authority)
  field(:failOpen)
  field(:forwardHeaders, type: :list)
  field(:metadata, type: :map)
  field(:name)
  field(:service)
  field(:supportedEvents, type: :list)
  field(:timeout)
end

defimpl Poison.Decoder, for: GoogleApi.NetworkServices.V1.Model.ExtensionChainExtension do
  def decode(value, options) do
    GoogleApi.NetworkServices.V1.Model.ExtensionChainExtension.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.NetworkServices.V1.Model.ExtensionChainExtension do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
